package com.wondersgroup.robot.common;

import java.io.UnsupportedEncodingException;

public class Nehnre {

	public static String  decode(String str) throws UnsupportedEncodingException{
		if(str != null && !"".equals(str.trim())){
			return java.net.URLDecoder.decode(str.replaceAll("@", "%"), "utf-8");
		}
		return "";
	}
	public static String encode(String str) throws UnsupportedEncodingException{
		if(str != null && !"".equals(str.trim())){
			str = str.replaceAll(" ", "%20");
			return java.net.URLEncoder.encode(str, "utf-8").replaceAll("%", "@");
		}
		return "";
	}
	public static void main(String args[]){
		try {
			System.out.println(encode("助力上海市公益科技网站 为研发平台投上宝贵一票"));
			System.out.println(java.net.URLDecoder.decode("a%20b", "utf-8"));
			
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
